package com.example.rabbitmq.demo5_lazy_mode;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Author songyahui
 * @Date 2023/7/13 14:58
 * @Description
 */
@Slf4j
@Component
public class LazyModeConsumer {

    @RabbitListener(queues = "lazy_mode_queue")
    public void receiveConfirmMessage(Channel channel, Message message) throws IOException {
        log.warn("懒惰队列！消息：{}", new String(message.getBody()));
//        配置文件开启配置：spring.rabbitmq.listener.simple.acknowledge-mode=manual，才能执行basicAck等手动应答方法
//        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}
